//work 콘텐츠 팝업
var settNum;

//work contants section hover
var ya = 0;
var $work_sec = $('section').not('.mob_hide');

//img click
function pop_layer() {
    $(".work_sec").each(function(i) {
        $(this).click(function() {
            var prjCode = $(this).attr("prjcode");
            ajax_view(prjCode);
        });
    });
}

//h2 click
$work_sec.find('h2').bind('click', function() {
    var setting = $(this).closest('section').index();

    work_pop(setting);
});

//contants mouse enter
/*
$work_sec.each(function(e){
	$work_sec.eq(e).bind('mouseenter', function(){
		hover_dark(e); //contants hover...
		$('.hover_dark').bind('click', function(){
			var setting =  $(this).closest('section').index();

			work_pop(setting);
		});
	});
});
*/

//contants mouse leave
$work_sec.bind('mouseleave', function() {
    $(this).find('.hover_dark').animate({
        'opacity': '0'
    }, {
        duration: 300,
        queue: false,
        complete: function() {
            $(this).remove();
        }
    });
});

function hover_dark($hover_this) {
    var dark_wt = $('.common_con section > a > img').width();
    var dark_ht = $('.common_con section > a > img').height();

    $work_sec.eq($hover_this).append('<div class="hover_dark"></div>');

    $('.hover_dark').css({
        'width': dark_wt,
        'height': dark_ht
    });

    $work_sec.eq($hover_this).find('.hover_dark').animate({
        'opacity': '0.5'
    }, {
        duration: 300,
        queue: false
    });

    $work_sec.eq($hover_this).siblings().find('.hover_dark').animate({
        'opacity': '0'
    }, {
        duration: 300,
        queue: false,
        complete: function() {
            $(this).remove();
        }
    });
};

//gnb클릭이벤트

var navNum = 0;
var gnbNum = 0;

//contants delay animation
function delay_animation() {
    //첫번재 페이지 실행	
    if (paging_num == 0) {
        $(".motion_data").each(function(e) {
            var $work_img = $(".motion_data");
            //var $work_img = $(".motion_data").find("a>img");
            var time = e * 150,
                work_width = $work_img.width();

            $work_img.css({
                'opacity': '0'
            });

            $work_img.eq(e).stop().delay(time).animate({
                'opacity': '1'
            }, {
                duration: 500
            });

        });
        //class명 추가.
        $(".motion_data").removeClass("motion_data");
    } else {
        $(".motion_data").each(function(e) {
            var $work_img = $(".motion_data");
            //var $work_img = $(".motion_data").find("a>img");
            var time = e * 150,
            work_width = $work_img.width();
            
            $work_img.css({'opacity': '0'});

            $work_img.eq(e).stop().delay(time).animate({'opacity': '1'}, {duration: 500});

        });
        $(".motion_data").removeClass("motion_data");
    }
}





$(document).ready(function() {
    var $search = $('.search'),
        $searchWrap = $('.searchWrap'),
        $category = $('.category'),
        $overlayForSearch = $('.overlayForSearch'),
        $wrap_inner = $('.wrap_inner'),
        $searchCloseWrap = $('.searchCloseWrap');
    $category.height(0);

    $('.work_sec').bind('mouseenter', function() {
        var dex = $(this).children('a').children('img').attr('src');



        var name_all = dex.split('/');
        var name_lt = name_all[1].split('.')
        var cut = name_lt[0] + '_hover'

        $(this).children('a').children('img').attr('src', '/resources/image/' + cut + '.jpg');

        $(this).bind('mouseleave', function() {
            $(this).children('a').children('img').attr('src', dex)
        });
    });

    $('.mob_hide').bind('click', function() {
        // alert('asdf')
        //$('.mob_hide img').attr('src','/resources/image/plus_secton_hover.jpg')
    });




    var open_gnbNum = 0;
    var winwt = BrowserSize().width;
    var gnb_wt = 50;

    if (winwt < 768) {
        $('.wppr_text ul li:nth-child(even)').css({
            'margin': '0'
        });
    } else if (winwt >= 768 && winwt < 1024) {
        $('.wppr_text ul li:nth-child(even)').css({
            'color': 'red'
        });
    } else if (winwt >= 1024 && winwt < 1280) {
        //alert('pc sm')
    } else if (winwt >= 1280 && winwt < 1420) {
        //alert('pc big')
    } else if (winwt >= 1420) {
        //alert('pc big2')
    }

    /* 
$('.open_gnb').bind('click', function(){
	gnbOpen();
	dim_size();
	open_gnbNum = 1;
});

$('.gnb_close_btn').bind('click', function(){
	gnbClose();
	open_gnbNum = 0;
});

$('.nav_gnb ul').each(function(){
	$(this).find('li:last').css({
		'border-right':'0'
	});
});

function gnbOpen(){
	$('.nav_gnb').animate({
		'left':'0'
	}, {duration:200, queue:false});
	$('.gnb_close_btn').show();
	$('.gnb_close_btn').animate({
		'opacity':'1'
	}, {duration:300, queue:false});
	$('.dim').show();
	$('.dim').animate({
		'opacity':'0.8'
	}, {duration:200, queue:false});
	open_gnbNum = 1;
}

function gnbClose(){
	$('.nav_gnb').animate({
		'left':-gnb_wt+'%'
	},  {duration:200, queue:false});
	$('.gnb_close_btn').animate({
		'opacity':'0'
	},  {duration:300, queue:false});
	$('.gnb_close_btn').hide();
	$('.dim').animate({
		'opacity':'0'
	}, {duration:200, queue:false, complete:function(){
		$('.dim').hide();
	}});
	open_gnbNum = 0;
}
*/


    //work_sec_comm(); 2014-01-13 변경

    /*-----------------------------------------------------------------------------------------*/
    /*-----------------------------------------------------------------------------------------*/
    /*---------------------------------- vcomm. vlab메뉴 start----------------------------------*/
    /*-----------------------------------------------------------------------------------------*/
    /*-----------------------------------------------------------------------------------------*/
    var mi_wt = BrowserSize().width;

    //대메뉴 클릭시
    $('.nav_inner > ul.gnb_box > li').bind('click', function() {


        var navIndex = $(this).index();
        mi_wt = BrowserSize().width;
        var mi_ht = $(window).height();

        var te = $('.nav_category li').eq(0).offset();
        var te2 = $('#nav').offset();

        $('.nav_arrow').css({
            'left': (te.left - te2.left) + 5
        });
        $('.nav_category li').eq(0).siblings().css({
            'opacity': '0.3'
        }).find('.iconOver').css({
            'opacity': '0'
        });
        $('.nav_category li').eq(0).css({
            'opacity': '1'
        }).find('.iconOver').css({
            'opacity': '0'
        });
        gnbNum = navIndex;

        gAnimate(navIndex);
        // console.log('navIndex : ' + navIndex);
        nav_index = 0;
        //nav_index 값 초기화.
        $('.category_list1 li').removeClass('selected');
        $('.comm_category li').eq(0).addClass('selected');
        $('.lab_category li').eq(0).addClass('selected');

    });
    //click

    function gAnimate(navIndex) {
            var eas = 'easeInSine';
            var speed = 300;

            //-------------------------vcomm 대메뉴 클릭
            if (navIndex == 0) {
                num = 0;

                $category.animate({
                    'height': '0'
                }, {
                    duration: speed,
                    queue: false,
                    easing: eas,
                    complete: function() {
                        searchButtonAction("close");
                        cat_state = $('.comm_category').height();

                        /*gnb_box 이미지변경*/
                        $('.gnb0').find('img').attr('src', '/resources/image/list_0_on.png');
                        $('.gnb1').find('img').attr('src', '/resources/image/list_1.png');
                        $('.crossLine').find('img').attr('src', '/resources/image/icon/bg_crossline0.png');

                        if (BrowserSize().width < 768) {
                            // cat_state = $searchWrap.height();
                            cat_state = 46;
                            searchButtonAction("open");
                            // 클래스 추가 액션
                            $searchWrap.siblings().hide();
                            // 검색 입력칸 외 서브 메뉴들 가리기
                            $('.category ul').eq(0).hide();
                            //  이건 왜 있는거지?

                        } else if (BrowserSize().width >= 768) {
                            // cat_state = 260;
                            $('.comm_category').siblings().hide();
                            // 카테고리 정렬 외 서브 메뉴들 가리기
                            $('.category_bar').show();
                            // 하단 바 노출
                            $('.comm_category').show();
                            // 카테고리 정렬만 나타나기
                        }
                        //end if 768 size 

                        $category.animate({
                            'height': cat_state
                        }, {
                            duration: speed,
                            queue: false,
                            easing: eas,
                            complete: function() {
                                // 서브메뉴 공간 높이를 위 높이 값 가져와서 지정하기
                                wt_state = $('.comm_category li').eq(0).width() + 17;
                                // 하단바 움직여야하니 크기를 잡아 놓는다.
                                $('.category_bar').css({
                                    'left': '0',
                                    'width': wt_state
                                });
                                // 일단 완료되면 하단 바 크기 조정
                                //css
                            }
                        });
                        //end animate						
                    }
                });
                //end animate
            }
            //-------------------------vlab 대메뉴 클릭
            else if (navIndex == 1) {
                num = 0;
                $category.animate({
                    'height': '0'
                }, {
                    duration: speed,
                    queue: false,
                    easing: eas,
                    complete: function() {
                        searchButtonAction("close");

                        var cat_state2 = $('.lab_category').height();

                        /*gnb_box 이미지변경*/
                        $('.gnb0').find('img').attr('src', '/resources/image/list_0.png');
                        $('.gnb1').find('img').attr('src', '/resources/image/list_1_on.png');
                        $('.crossLine').find('img').attr('src', '/resources/image/icon/bg_crossline1.png');

                        if (BrowserSize().width < 768) {
                            // console.log("줄어라")
                            // cat_state2 = 260;
                            cat_state2 = 46;
                            searchButtonAction("open");

                            $searchWrap.siblings().hide();
                            $('.category ul').eq(3).hide();

                        } else if (BrowserSize().width >= 768) {
                            // cat_state2 = 260;
                            $('.lab_category').siblings().hide();
                            $('.category_bar').show();
                            $('.lab_category').show();
                        }
                        //end if 768 size

                        $category.animate({
                            'height': cat_state2
                        }, {
                            duration: speed,
                            queue: false,
                            easing: eas,
                            complete: function() {
                                wt_state = $('.lab_category li').eq(0).width() - 7;

                                $('.category_bar').css({
                                    'left': '0',
                                    'width': wt_state
                                });
                                //css
                            }
                        });
                        //animate
                    }
                });
                //animate
            }
            //if


            if (navIndex == navNum) {
                return;
            } else {
                $('#wrap').append('<div class="move_img" style="background-color:black; opacity:0.5; position:fixed; top:0; z-index:10000"></div>');
                $('.common_con').eq(navIndex).show();
                $('.common_con').eq(navIndex).siblings().hide();
                $('.move_img').animate({
                    'left': -mi_wt
                }, {
                    duration: 300,
                    queue: false,
                    complete: function() {
                        $(this).remove();
                    }
                });
                //end animate
                navNum = navIndex;
            }
            //if

        }
        /*-----------------------------------------------------------------------------------------*/
        /*-----------------------------------------------------------------------------------------*/
        /*---------------------------------- vcomm. vlab메뉴 end----------------------------------*/
        /*-----------------------------------------------------------------------------------------*/
        /*-----------------------------------------------------------------------------------------*/



    //vcomm vlab 네비게이션 호버
    //대메뉴 
    $('.nav_inner > ul > li').hover(function() {
        var _this = $(this),
            now_hov = _this.index();

        if (now_hov == navNum) {
            return false;
        } else {
            _this.animate({
                'opacity': '0.5'
            }, {
                duration: 300,
                queue: false
            });
            // _this.find('.iconOver').fadeOut();
        }
    }, function() {
        var _this = $(this);
        _this.animate({
            'opacity': '1'
        }, {
            duration: 300,
            queue: false
        });
        // _this.find('.iconOver').fadeIn();
    });




    var num = 0; //lnb 비교변수
    var arrow_wt = 7; //arrow width()/2
    var category_index = 0; //category index 비교변수
    var category_index2 = 0; //category index 비교변수


    var nav_off = $('#nav').offset();
    var box_off = $('.nav_category > li').eq(num).offset();
    var box_wt = $('.nav_category > li').width() / 2;

    var list_offset = $('.category_list1 li').eq(category_index).offset();
    var list_offset2 = $('.category_list3 li').eq(category_index2).offset();
    var wt_offset = $('.category').offset();



    //lnb animation함수
    function lnb_move(nav_off, box_off, box_wt) {
        $('.nav_arrow').animate({
            'left': (box_off.left - nav_off.left) + box_wt - arrow_wt
        }, {
            duration: 400,
            queue: false,
            easing: 'easeOutQuart'
        });
    }

    category_bar(list_offset)
    category_bar2(list_offset2)

    lnb_move(nav_off, box_off, box_wt);

    $('.nav_category > li:not(:eq(0))').css({
        'opacity': '0.3'
    });
    $('.nav_category > li').find('.iconOver').css({
        'opacity': '0'
    });

    //카테고리 호버
    $('.nav_category > li').hover(function() {
        var now_catIndex = $(this).index();
        // console.log(num)
        if (now_catIndex == num) {
            return false;
        } else {
            $(this).animate({
                    'opacity': '0.5'
                }, {
                    duration: 300,
                    queue: false
                })
                .find('.iconOver').animate({
                    'opacity': '0.5'
                }, {
                    duration: 300,
                    queue: false
                });
        }
    }, function() {
        var now_catIndex = $(this).index();


        if (now_catIndex == num) {
            return false;
        } else {
            $(this).animate({
                    'opacity': '0.3'
                }, {
                    duration: 300,
                    queue: false
                })
                .find('.iconOver').animate({
                    'opacity': '0'
                }, {
                    duration: 300,
                    queue: false
                });
        }
    });

    var nav_index = 0,
        showht;
    //조건순 정렬에 대한 버튼 액션
    $('.nav_category > li').bind('click', function() {
        nav_index = $(this).index(); //카테고리 리스트
        var nav_off = $('#nav').offset();
        var box_off = $(this).offset();
        var box_wt = $(this).width() / 2;
        showht = $('.category ul').eq(nav_index).height();



        $(this).animate({
                'opacity': '1'
            }, {
                duration: 200,
                queue: false
            })
            .find('.iconOver').animate({
                'opacity': '0'
            }, {
                duration: 200,
                queue: false
            });

        $(this).siblings().animate({
                'opacity': '0.3'
            })
            .find('.iconOver').animate({
                'opacity': '0'
            }, {
                duration: 200,
                queue: false
            });



        $('.category').animate({
            'height': '0'
        }, {
            duration: 300,
            queue: false,
            complete: function() {

                $('.category ul').hide();
                $('.category ul').eq(nav_index).show();

                $('.category').animate({
                    'height': showht
                }, {
                    duration: 300,
                    queue: false
                });

                if (gnbNum == 1 && nav_index == 0) {
                    // vlab 눌렀을 때
                    $('.category ul').eq(0).hide();
                    $('.category ul').eq(3).show();
                }

                if (nav_index == 0) {
                    //첫번쨰 카테고리 선택시 - 카테고리
                    searchButtonAction("close");
                    $('.total_cat').hide();

                    if (gnbNum == 0) {
                        //vcomm 눌렀을 때
                        cat_state = $category.children().eq(0).height();
                        $category.children().eq(0).siblings().hide();
                        wt_state = $('.comm_category li').eq(0).width() + 17;
                        $('.category_bar').show().css({
                            'width': wt_state
                        });

                    } else {
                        //vlab 눌렀을 때
                        cat_state = $category.children().eq(4).height();
                        $category.children().eq(4).siblings().hide();
                        wt_state = $('.lab_category li').eq(0).width() - 7;
                        $('.category_bar').show().css({
                            'width': wt_state
                        });
                    }
                    $('.category').animate({
                        'height': cat_state
                    }, {
                        duration: 300,
                        queue: false
                    });
                    //end if gnbnum 1	

                } else {
                    $('.category_bar').hide();
                }
                //end nav_index 0

                if (nav_index == 1) {
                    //두번쨰 카테고리 선택시 - 태그
                    searchButtonAction("close");
                    showht = $('.category ul').eq(nav_index).height();
                    $('.category').animate({
                        'height': showht + 10
                    }, {
                        duration: 300,
                        queue: false
                    });

                } else {
                    $('.total_cat').hide();
                    $('.category_bar').show();
                }
                //end nav_index 1

                if (nav_index == 2) {
                    //세번쨰 카테고리 선택시 - 년도순
                    searchButtonAction("close");
                    $('.total_cat').hide();
                    $('.category').animate({
                        'height': showht
                    }, {
                        duration: 300,
                        queue: false
                    });


                } else {
                    $('.category_bar2').hide();
                }
                //end n	av_index 2					

                if (nav_index == 3) {
                    //네번째 카테고리 선택시 - 검색
                    //input 상자만 따로 분기
                    $('.search').val("");
                    //검색어 초기화.
                    // $('.search').show();
                    $searchWrap.siblings().hide();
                    $('.total_cat').hide();
                    // var search_ht = $('.search').height(); //검색 입력칸 구조 변경으로 주석
                    if (BrowserSize().width < 768) {
                        search_ht = 46;
                    } else {
                        search_ht = 260;
                    }
                    searchButtonAction("open");
                    // $search.focus(); 모바일에서 자판 나타나는 현상 때문에 주석처리함
                    $('.category').animate({
                        'height': search_ht + 'px'
                    }, {
                        duration: 300,
                        queue: false
                    });

                    // return;
                } else {
                    // searchButtonAction("close");
                }
                //end nav_index 3
            }
        });


        lnb_move(nav_off, box_off, box_wt);

        num = nav_index;

    });

    function searchButtonAction(val) {
            var _val = val;
            if (val == "close") {
                $category.removeClass('categorySearch');
                $searchWrap.hide();
                // $overlayForSearch.css("display","none");
                // nav_index = 0;
            } else if (val == "open") {
                $category.addClass('categorySearch');
                $searchWrap.show();
                /*if(BrowserSize().width < 768){
					$overlayForSearch.css("display","none");
				}else{
					$overlayForSearch.css("display","block");
				}*/
                //end if
            }
            //if
        }
        //end fn.searchButtonAction
    $('.searchCloseButton').click(function() {
            nav_index = 0;
            $('.nav_category > li').eq(0).click();
            // gAnimate(0);
            // showht = $('.category ul').eq(0).height();
        })
        //end click

    $('.con_close').bind('click', function() {
        $('#wrap').css({
            'position': 'relative',
            'top': '0',
            'left': '0',
            'margin-left': '0'
        });
        //Vimeo 영상 제거.
        $(".vimeo_frm_new").attr("src", "");
        $(".vimeo_frm").attr("src", "");
        $(".work_pop").find(".work_pop_con").find("img").attr("src", "/resources/image/cover.png");
        $(".work_pop_old").find(".work_pop_con").find("img").attr("src", "/resources/image/cover.png");

        //대표 영상 제거.
        $(".work_pop_old").find("object").eq(0).parent().parent().append("<div class='jwplayer_class' id='' style='display:none;'></div>");
        $(".work_pop_old").find("object").eq(0).parent().parent().find("div").eq(0).remove();
        $(".work_pop_old").find("#video_src").val("");
        $(".work_pop_old").find("#video_src").attr("seq", "");
        $(".work_pop_old").find("#video_src").attr("thum_img", "");

        $('.work_article').show();
        // $('.article_culture').show();
        $('footer').show();
        if (BrowserSize().width <= 1279) {
            // $('.article_culture').hide();
        }
        $('.work_pop').hide();
        $('.work_pop_old').hide();

        $('.work_dim').hide();
        $(window).scrollTop(settNum);
    });

    $('.popcon_mission').each(function() {
        $(this).find('p:last').css({
            'margin-bottom': '0'
        });
    });

    //about 시퀀스


    $('.nav_gnb_inner li').bind('click', function() {
        open_gnbNum = 0;
    });




    //리사이즈 이벤트
    $(window).resize(function() {
        var win_th = window.innerWidth;
        resizeEvent();
        //var wt = $('#wrap').width();
        //var ht = $('#wrap').height();


        /*if(winwt < 768){
		//$('.wppr_text ul li:nth-child(even)').css({
		//	'margin':'0'
		//});
		//$('.category_bar').show();
	} else if(winwt >= 768 && winwt < 1024){
		//$('.wppr_text ul li:nth-child(even)').css({
		//	'margin':'0 20px 10px 0'
		//});
	} else if(winwt >= 1024 && winwt < 1280){
		//alert('pc sm')
	} else if(winwt >= 1280 && winwt < 1420){
		//alert('pc big')
	} else if(winwt >= 1420){
		//alert('pc big2')
	}

	if(win_th >= 768){
		$('.nav_gnb').css({
			'left':'0'
		});
		$('.gnb_close_btn').animate({
			'opacity':'0'
		},  {duration:300, queue:false});
		$('.gnb_close_btn').hide();
		$('.dim').hide();
		$('.search').hide();
	
	} else if(win_th < 768){
		if(open_gnbNum == 0){ 
		//gnb닫혀있을시
			//2014-05-16 gnbClose();
		} else if(open_gnbNum == 1){ 
		//gnb open시
			$('.gnb_close_btn').css('opacity','1')
			$('.gnb_close_btn').show();
			$('.dim').show();
		}
		$('.search').show();
	}*/

        /*
	else if($('.nav_gnb').width() < 1180 && $('.nav_gnb').css('left') != '0px') {
		$('.nav_gnb').css({
			'left':-gnb_wt+'%',
			'margin':'0'
		});
	} else if(BrowserSize().width < 768 && $('.nav_gnb').css('left') == '0px'){
		$('.nav_gnb').css({
			'left':-50+'%'
		});
		$('.gnb_close_btn').animate({
			'opacity':'0'
		},  {duration:300, queue:false});
		$('.gnb_close_btn').hide();
		$('.dim').hide();
	} else if($('.nav_gnb').width() >= 1420){
		$('.nav_gnb').css({
			'left':'50%',
			'margin-left':'-710px'
		});
		$('.gnb_close_btn').animate({
			'opacity':'0'
		},  {duration:300, queue:false});
		$('.gnb_close_btn').hide();
		$('.dim').hide();
	}
	*/




    });
    /* 브라우져 사이즈 레퍼런스 */
    var $windowWidth = $('.windowWidth'),
        $windowHeight = $('.windowHeight'),
        $InnerWidth = $('.InnerWidth'),
        $InnerHeight = $('.InnerHeight'),
        $RealWidth = $('.RealWidth'),
        $RealHeight = $('.RealHeight'),
        ie8lte = false,
        browserScaleUp = false,
        _orgWidth = BrowserSize().width;
    (function CheckIe() {
        if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)) {
            var ieVer = new Number(RegExp.$1);
            if (ieVer <= 8) {
                ie8lte = true;
            }
            //if
        }
        //if
    })();

    function BrowserSize() {
            var _window = window,
                _inner = 'inner';
            if (!('innerWidth' in window)) {
                _inner = 'client';
                _window = document.documentElement || document.body;
            }

            if (!ie8lte) {
                // ie8 이하이지 않을 때
                return {
                    width: _window[_inner + 'Width'],
                    height: _window[_inner + 'Height']
                }
            } else {
                //  ie8 이하일 때
                if (!browserScaleUp) {
                    // 브라우저를 줄일 경우
                    return {
                        width: _window[_inner + 'Width'] + 0,
                        height: _window[_inner + 'Height'] + 0
                    }
                } else {
                    // 브라우저를 키울 경우
                    return {
                        width: _window[_inner + 'Width'] - 6,
                        height: _window[_inner + 'Height'] - 6
                    }
                }
            }
        }
        // fn. BrowserSize
        /* 브라우져 사이즈 레퍼런스 끝*/

    //resize

    function resizeEvent() {
        //work lnb하단 화살표
        var nav_off = $('#nav').offset();
        var box_off = $('.nav_category > li').eq(num).offset();
        var box_wt = $('.nav_category > li').width() / 2;
        //category_bar
        var list_offset = $('.category_list1 li').eq(category_index).offset();
        var wt_offset = $('.category_list1').offset();

        var list_offset2 = $('.category_list3 li').eq(category_index2).offset();
        var common_ht = $('.category ul').eq(num).height();

        lnb_move(nav_off, box_off, box_wt);

        //top bar
        //top_bar();


        if (gnbNum == 1) {
            list_offset = $('.lab_category li').eq(category_index).offset();
        }
        category_bar(list_offset)
        category_bar2(list_offset2)

        if (BrowserSize().width < 768) {
            // 리사이즈 했을 때 768px 미만이면

            $('.category ul').hide();
            // 모든 서브 메뉴들 숨기고
            if (nav_index !== 3) {
                // 현재 선택된 정렬조건이 검색이 아니라면
                nav_index = 3;
                //  현재 정렬 조건을 검색으로 만들어 놓는다.

                // 정렬 조건을 검색으로 클릭한 기능을 실행한다.
                $('.nav_category > li:not(:eq(3))').css({
                    // 정렬 조건 아이콘에서 검색을 제외한 것들은 다 반투명하게 만든다.
                    'opacity': '0.3'
                });
                $('.nav_category > li').eq(3).css({
                    'opacity': '1'
                });
                // $('.category').height('46px');
            }
            // end nav_index
            $('.search').val("");
            //검색어 초기화.
            $searchWrap.siblings().hide();
            $('.total_cat').hide();
            searchButtonAction("open");
            $('.category').height('46px');
            // $search.focus();				모바일에서 자판 나타나는 현상 때문에 주석처리함

            // $('.nav_category > li').eq(3).click();
        } else {
            //  리사이즈 크기가 768px 이상일 경우에는
            // $('.category ul').eq(num).show();
            //  현재 정렬 조건 고유 넘버를 가져와서 해당 엘리먼트를 보여준다.

            if (nav_index == 1) {
                // 정렬 조건이  태그일 경우에는 +10을 주어 간격을 조금 높인다.
                $('.category').height(common_ht + 10);
            } else if (nav_index == 3) {
                //정렬 조건이 검색을 경우에는 아무런 변화가 없게 만든다.					
                $('.category').height('260px');
            } else {
                // 정렬조건이 태그도 아니고 검색도 아닌 카테고리, 일정별이라면 해당 서브메뉴 컨텐츠 높이의 값을 가져와서 넣는다.
                $('.category').height(common_ht);
            }
            //if												

        }
        //end if	
    }
    resizeEvent();




    //category
    $('.category_list1 li').hover(function() {
        $(this).siblings().animate({
            'opacity': '0.3'
        }, {
            duration: 200,
            queue: false
        });
    }, function() {
        $(this).siblings().animate({
            'opacity': '1'
        }, {
            duration: 200,
            queue: false
        });
    });



    $('.comm_category li').bind('click', function() {
        var list_index = $(this).index();
        var cateList_offset = $(this).offset();

        category_index = list_index;

        category_bar(cateList_offset);
        $('.comm_category li').removeClass('selected');
        $(this).addClass('selected');
        console.log("this index : " + list_index)
    });
    $('.lab_category li').bind('click', function() {
        var list_index = $(this).index();
        var cateList_offset = $(this).offset();

        category_index = list_index;
        category_bar(cateList_offset);

        $('.lab_category li').removeClass('selected');
        $(this).addClass('selected');
        // console.log("this index : " + list_index)
    });

    $('.category_list3 li').bind('click', function() {
        var list_index = $(this).index();
        var cateList_offset = $(this).offset();

        category_index2 = list_index;

        category_bar2(cateList_offset);
    });


    //카테고리 하단bar
    function category_bar(list_offset) {
        if (gnbNum == 0) {
            //vcomm일 때
            var wt_offset = $('.comm_category').offset();

            $('.category_bar').width($('.category_list1 > li').width() + 17);
            category_bar_left = list_offset.left - wt_offset.left;
        } else if (gnbNum == 1) {
            //vlab일 때
            var wt_offset = $('.lab_category').offset();

            if (BrowserSize().width < 1024) {
                category_bar_left = list_offset.left - wt_offset.left - 24;
            } else {
                category_bar_left = list_offset.left - wt_offset.left - 17;
            }
            $('.category_bar').width($('.lab_category > li').width() + 17);
        }


        $('.category_bar').animate({
            'left': category_bar_left
        }, {
            duration: 200,
            queue: false
        });
    }

    //카테고리 하단bar2
    function category_bar2(list_offset2) {
        var wt_offset = $('.category_list3').offset();

        $('.category_bar2').width($('.category_list3 > li').width());

        $('.category_bar2').animate({
            'left': list_offset2.left - wt_offset.left
        }, {
            duration: 200,
            queue: false
        });
    }

    /*
    		$('.dim').width($('#wrap').width());
    		$('.dim').height($('#wrap').height());

    		//gnb 상단 bar호출
    		top_bar();
    		
    */
    /* 잠시 주석 처리. 2014-01-14
//work index번호 가져가기
if(flow_index != null){
	work_pop(flow_index);
}
*/


    //contact us
    $('.map_start').bind('click', function() {
        $(".map_iframe").attr("src", "map.html");
        $('.map_pop').css({
            'z-index': '1000',
            'visibility': 'visible'
        });
        $(window).scrollTop(0);

        var gnb_wt = 50;

        if (BrowserSize().width <= 768) {
            $('.nav_gnb').animate({
                'left': -gnb_wt + '%'
            }, {
                duration: 200,
                queue: false
            });
        } else {
            return;
        }
        $('.gnb_close_btn').animate({
            'opacity': '0'
        }, {
            duration: 300,
            queue: false
        });
        $('.gnb_close_btn').hide();
        $('.dim').animate({
            'opacity': '0'
        }, {
            duration: 200,
            queue: false,
            complete: function() {
                $('.dim').hide();
            }
        });
    });

    $('.map_close').bind('click', function() {
        $('.map_pop').css({
            'visibility': 'hidden',
            'z-index': '-100'
        });
    });

});
/*docuemnt.ready end*/




//탑 화살표
/* 2014-05-16 제거 
function top_bar(){
	var move_set = $('.gnb_on').offset();
	var move_set_wrap = $('.nav_gnb_inner').offset();
	var move_wt = $('.gnb_on').width()+22;
	
	$('.top_bar').css({
		'width' : move_wt
	});
	$('.top_bar').css({
		'left' : move_set.left
	});
}
*/


function work_pop(type) {
    var no_scr = $(window).height();
    var no_scr_ht = $('.wrap_inner').width() / 2;

    settNum = $(window).scrollTop();

    $('#wrap').css({
        'position': 'fixed',
        'top': '0',
        'left': '50%',
        'margin-left': -no_scr_ht
    });
    $('.work_article').hide();
    // $('.article_culture').hide();
    $('footer').hide();

    if (type == 0) {
        $('.work_pop').show();
    } else {
        $('.work_pop_old').show();
    }

    $('.work_dim').show();
    $(window).scrollTop(0);
}

//Tag 클릭 모션
function tag_category_motion() {
    //두번째 카테고리 내부
    $('.category_list2 li').hover(function() {
        $(this).siblings().animate({
            'opacity': '0.3'
        }, {
            duration: 300,
            queue: false
        });
    }, function() {
        $(this).siblings().animate({
            'opacity': '1'
        }, {
            duration: 300,
            queue: false
        });
    });

    $('.category_list2 li').bind('click', function() {
        $(this).css({
            'background-color': '#7359d1'
        });
        $(this).find('a').css({
            'color': '#e9e9e9'
        });
        $(this).find('a').css({
            'background-color': '#7359d1'
        });
        $(this).siblings().css({
            'background-color': '#e9e9e9'
        });
        $(this).siblings().find('a').css({
            'color': '#191919'
        });
        $(this).siblings().find('a').css({
            'background-color': '#e9e9e9'
        });

        /*
		if(gnbNum == 0){
			$(this).css({
				'background-color':'#191919'
			});
			$(this).find('a').css({
				'color':'#e9e9e9'
			});
			$(this).find('a').css({
				'background-color':'#191919'
			});
			$(this).siblings().css({
				'background-color':'#e9e9e9'
			});
			$(this).siblings().find('a').css({
				'color':'#191919'
			});
			$(this).siblings().find('a').css({
				'background-color':'#e9e9e9'
			});

		} else if(gnbNum == 1){
			$(this).css({
				'background-color':'white'
			});
			$(this).find('a').css({
				'color':'#191919'
			});
			$(this).find('a').css({
				'background-color':'white'
			});
			$(this).siblings().css({
				'background-color':'#191919'
			});
			$(this).siblings().find('a').css({
				'color':'white'
			});
			$(this).siblings().find('a').css({
				'background-color':'#191919'
			});
		}
		*/
    });
}


function date_category_motion() {
    $('.category_list3 li').hover(function() {
        $(this).siblings().animate({
            'opacity': '0.3'
        }, {
            duration: 300,
            queue: false
        });
    }, function() {
        $('.category_list3 li').animate({
            'opacity': '1'
        }, {
            duration: 300,
            queue: false
        });
    });
}


//more btn motion
function check_slide($mypick) {
    var check_position = $mypick.offset();
    var scroll_position = check_position.top - 100;

    $('html, body').animate({
        scrollTop: scroll_position
    }, {
        duration: 500,
        easing: 'easeInOutExpo'
    });
}